import request from "@/apis/request";

export const findProcess = async (form, currentPage, pageSize) => {
    return await request.get("api/process/find", {
        params: {
            procedureCode: form.procedureCode,
            procedureName: form.procedureName,
            isEnabled: form.isEnabled,
            currentPage: currentPage,
            pageSize: pageSize
        }
    })
}
export const findProcessById = async (id) => {
    return await request.get("api/process/findById", {
        params: {
            id: id
        }
    })
}
export const addProcess = async (form) => {
    return await request.post("api/process/insert", form)
}
export const updateProcess = async (form) => {
    return await request.put("api/process/update", form)
}
export const deleteProcess = async (id) => {
    return await request.delete("api/process/delete", {data: id})
}

// 工序详情
export const findDetails = async (id) => {
    return await request.get("api/process/findDetails", {
        params: {processCode: id}
    })
}
// 添加工序详情
export const addDetailsProcess = async (form) => {
    return await request.post("api/process/insertDetailsProcess", form)
}
// 修改工序详情
export const updateDetailsProcess = async (form) => {
    return await request.put("api/process/updateDetailsProcess", form)
}
// 删除工序详情
export const deleteDetailsProcess = async (id) => {
    return await request.delete("api/process/deleteDetailsProcess", {data: id})
}

// 查询工艺流程中产品是否唯一
export const findProduct = async (productCode,num) => {
    return await request.get("api/process/findProduct", {
        params: {productCode: productCode,p:num}
    })
}
// 添加产品到工艺路线中
export const addProduct = async (form) => {
    return await request.post("api/process/insertProduct", form)
}
// 修改产品
export const updateProduct = async (form) => {
    return await request.put("api/process/updateProduct", form)
}
// 删除产品
export const deleteProduct = async (id) => {
    return await request.delete("api/process/deleteProduct", {data: id})
}
// 查询产品中有那些组成
export const findProductByProductCode = async (procedureCode) => {
    return await request.get("api/process/findProductByProductCode", {
        params: {procedureCode: procedureCode}
    })
}
// 将组成添加到相应的工艺路线中
export const addProductDetails = async (form) => {
    return await request.post("api/process/insertProductDetails", form)
}
// 将工艺路线中的组成删除
export const deleteProductDetails = async (id) => {
    return await request.delete("api/process/deleteProductDetails", {data: id})
}
// 修改工艺路线中的组成
export const updateProductDetails = async (productCode) => {
    return await request.put("api/process/updateProductDetails",productCode)
}